/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */

struct ListNode* reverseList(struct ListNode* head)
{
    struct ListNode* prve = NULL;
    struct ListNode* cur = head;
    struct ListNode* tail = NULL;
    while(cur)
    {
        tail = cur->next;
        cur->next = prve;
        prve = cur;
        cur = tail;
    }
    return prve;
}
bool isPalindrome(struct ListNode* head) {
        struct ListNode* slow = head, *fast = head;
        while(fast && fast->next)
        {
            slow = slow->next;
            fast = fast->next->next;
        }
        //走到这里slow指向的就是中间节点，如果是偶数，则指向第二个
        struct ListNode* headA = reverseList(slow);
        struct ListNode* headB = head;
        while(headA)
        {
            if(headA->val != headB->val) return false;
            headA = headA->next;
            headB = headB->next;
        }
        return true;
}